package voja.android.vwidget;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import android.app.Activity;

public class VWidgetActivity extends Activity {
    
	SharedPreferences prefs;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        prefs = getSharedPreferences(getApplicationInfo().packageName, MODE_PRIVATE);
        
        String colorText = prefs.getString("colorText", "#ffffff");
        String colorShadow = prefs.getString("colorShadow", "#000000");
        
        ((TextView)findViewById(R.id.txtColorText)).setText(colorText);
        ((TextView)findViewById(R.id.txtColorShadow)).setText(colorShadow);
    }
    
    public void save(View v) {
    	SharedPreferences.Editor edit = prefs.edit();
    	
    	String colorText = ((TextView)findViewById(R.id.txtColorText)).getText().toString();
        String colorShadow = ((TextView)findViewById(R.id.txtColorShadow)).getText().toString();
        
        edit.putString("colorText", colorText);
        edit.putString("colorShadow", colorShadow);
        
        String message = "Preferences saved.";
        if(!edit.commit()) {
        	message = "ERROR, Preferences are not saved!";
        }
        Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
    }
    
    public void close(View v) {
    	finish();
    }
}